import {Action, commit} from '@/store/Utils';
import {deepAssign} from '@/base/util/Objects';

export class DeviceState {
  deviceId = 0
}

abstract class BaseAction implements Action {
  namespace? = 'device';
}

class SetAction extends BaseAction {
  deviceId?: number;

  static typed(state: DeviceState, payload: SetAction): void {
    deepAssign(state, payload);
  }
}

export const device = {
  namespaced: true,
  state: new DeviceState(),
  getters: {},
  actions: {},
  mutations: {
    [SetAction.name]: SetAction.typed
  }
};

export class deviceBloc {
  static getDeviceId(deviceId: number) {
    commit(SetAction, {deviceId});
  };
}
